package sel.me.spring.boot245.web.config.security.handler;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;
import sel.me.spring.boot245.web.exception.UnifyStrErrorCode;
import sel.me.spring.boot245.web.utils.ResultUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 暂无权限返回结果
 * @author shenenlu
 * @date 2021-7-28 19:01
 */
@Component
public class UserAuthAccessDeniedHandler implements AccessDeniedHandler {
    /**
     * 暂无权限返回结果
     * @Author youcong
     */
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception){
        ResultUtil.responseJson(response, ResultUtil.resultError(UnifyStrErrorCode.FORBIDDEN));
    }
}